package com.zpself.module.spring.AOP.Proxy实现;

import com.zpself.module.spring.AOP.静态代理.MyMath;
import org.junit.Test;
import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;

/**
 * @author By ZengPeng
 * @Description
 * @date in  2021/3/24 20:34
 * @Modified By
 */
public class porxy生成的源码查看 {
    String path = "C:\\Users\\ying\\zpFile\\toolInstall\\newSourceTree\\mayunResouce\\DesignPattern\\src\\main\\java\\com\\zpself\\module\\spring\\AOP\\Proxy实现\\字节码.class";
    @Test
    public void create(){
        byte[] classFile = ProxyGenerator.generateProxyClass("$Proxy0", MyMath.class.getInterfaces());
        try(FileOutputStream fos = new FileOutputStream(path)){
            fos.write(classFile);
            fos.flush();
            System.out.println("代理类class文件写入成功");
        }catch (Exception e) {
            System.out.println("写文件错误");
        }

    }
}
